package com.cuc.platform.core.componet.security.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @author peepul
 * 
 * 系统认证用户类
 * 
 * ss_user表的对应POJO,字段名做了大小写处理.
 */
public class SecurityUser implements  Serializable{
	private static final long serialVersionUID = -7207958538391062712L;

	private Long id;// pk

	private String aliasName;//用户别名
	private String loginName;//登录账号
	private String password;
	private String salt;//盐值
	private String isAdmin;//是否系统管理账号
	private Integer status;//是否有效
	private String descn;
	private Long userinfo_id;
	private Long orgId;
	private String orgName;
	
	private List<SecurityRole> roles = new ArrayList<SecurityRole>();
	private SecurityRole role;

	/**
	 * 下面的属性 无需持久化
	 *  */
	@Transient
	@JsonIgnore
	private String plainPassword;//文本密码明文
	
	
	/**
	 * @return the orgId
	 */
	public Long getOrgId() {
		return orgId;
	}

	/**
	 * @param orgId the orgId to set
	 */
	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}


	/**
	 * @return the aliasName
	 */
	public String getAliasName() {
		return aliasName;
	}

	/**
	 * @param aliasName the aliasName to set
	 */
	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}
	
	/**
	 * @return the role
	 */
	public SecurityRole getRole() {
		return role;
	}

	/**
	 * @param role the role to set
	 */
	public void setRole(SecurityRole role) {
		this.role = role;
	}

	/**
	 * @return the userinfo_id
	 */
	public Long getUserinfo_id() {
		return userinfo_id;
	}

	/**
	 * @param userinfo_id the userinfo_id to set
	 */
	public void setUserinfo_id(Long userinfo_id) {
		this.userinfo_id = userinfo_id;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	/**
	 * @return the isAdmin
	 */
	public String getIsAdmin() {
		return isAdmin;
	}

	/**
	 * @param isAdmin the isAdmin to set
	 */
	public void setIsAdmin(String isAdmin) {
		this.isAdmin = isAdmin;
	}
	
	/**
	 * @return the roles
	 */
	public List<SecurityRole> getRoles() {
		return roles;
	}

	/**
	 * @param roles the roles to set
	 */
	public void setRoles(List<SecurityRole> roles) {
		this.roles = roles;
	}

	/**
	 * @param id
	 * the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 * the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the status
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param status
	 * the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the descn
	 */
	public String getDescn() {
		return descn;
	}

	/**
	 * @param descn
	 * the descn to set
	 */
	public void setDescn(String descn) {
		this.descn = descn;
	}

	/**
	 * @param id
	 * @param userName
	 * @param password
	 * @param status
	 * @param descn
	 */
	public SecurityUser(Long id, String loginName, String password,String salt,
			Integer status, String descn) {
		super();
		this.id = id;
		this.loginName = loginName;
		this.password = password;
		this.salt = salt;
		this.status = status;
		this.descn = descn;
	}

	/**
	 * 
	 */
	public SecurityUser() {
		super();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof SecurityUser))
			return false;
		final SecurityUser other = (SecurityUser) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getPlainPassword() {
		return plainPassword;
	}

	public void setPlainPassword(String plainPassword) {
		this.plainPassword = plainPassword;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	
}
